/**
 * Provides the ControlSystem class for handing all IEntity controls in a game.
 *
 * @file src/ControlSystem.hpp
 * @author Jacob Dix
 * @date 20120701 - Initial Release
 */
#ifndef CONTROL_SYSTEM_HPP_INCLUDED
#define CONTROL_SYSTEM_HPP_INCLUDED
#include <GQE/Entity/interfaces/ISystem.hpp>
#include <GQE/Entity/classes/Prototype.hpp>

class ControlSystem : public GQE::ISystem
{
  public:
    ControlSystem(GQE::IApp& theApp);

    virtual ~ControlSystem();

    /**
     * RegisterPrototype is responsible for adding the properties to a prototype.
     * @param[in] thePrototype is the prototype to use.
     */
    virtual void AddProperties(GQE::IEntity* theEntity);

    /**
     * HandleEvents is responsible for letting each Instance class have a
     * chance to handle theEvent specified.
     * @param[in] theEvent to handle
     */
    virtual void HandleEvents(sf::Event theEvent);

    /**
     * UpdateFixed is called a specific number of times every game loop and
     * this method will allow each Instance class a chance to have its
     * UpdateFixed method called for each game loop iteration.
     */
    virtual void UpdateFixed(void);

    /**
     * UpdateVariable is called every time the game loop draws a frame and
     * includes the elapsed time between the last UpdateVariable call for
     * use with equations that use time as a variable. (e.g. physics velocity
     * and acceleration equations).
     */
    virtual void UpdateVariable(float theElapsedTime);

    /**
     * Draw is called during the game loop after events and the fixed update
     * loop calls are completed and depends largely on the speed of the
     * computer to determine how frequently it will be called. This gives the
     * EntityManager a chance to call the Draw method for each Instance
     * class.
     */
    virtual void Draw(void);
  protected:
    /**
     * HandleInit is called to allow each derived ISystem to perform any
     * initialization steps when a new IEntity is added.
     */
    virtual void HandleInit(GQE::IEntity* theEntity);

    /**
     * HandleCleanup is called when the IEntity that was added is finally
     * dropped from this ISystem and gives the derived ISystem class a chance
     * to perform any custom work before the IEntity is deleted.
     */
    virtual void HandleCleanup(GQE::IEntity* theEntity);
  private:
};
#endif // CONTROL_SYSTEM_HPP_INCLUDED

/**
 * @class GQE::ControlSystem
 * The ControlSystem class is used to cause all IEntity classes registered to
 * have their velocity information updated according to the keyboard keys that
 * are currently pressed. The properties provided by this ISystem are as follows:
 * - Speed: The float which determines the speed of the player
 * - Health: The GQE::Uint32 value representing the current health of the player
 * - MaxHealth: The GQE::Uint32 value representing the maximum health of the player
 * - StartPosition: The sf::vector2f representing the starting position for the player
 * - Immune: The bool which is true if the player is immune to ???
 * - Dead: The bool which is true if the player has died
 * - Player: The bool which is true if this is the active player?
 * - ImmuneTimer: The sf::Clock that determines how long immunity will last
 * - DeadTimer: The sf::Clock that determines how long death will last
 * - GreenKey: The bool which is true if the player has the green key
 * - BlueKey: The bool which is true if the player has the blue key
 * - RedKey: The bool which is true if the player has the red key
 * - Bow: The bool which is true if the player has a bow
 * - Arrows: The GQE::Uint32 which counts the number of arrows the player has
 * The ControlSystem class makes use of the following properties provided by the
 * RenderSystem class:
 * - SpriteRect: The sf::IntRect currently being shown
 * - Visible: The bool which is true if the player should be drawn each frame
 * The ControlSystem class makes use of the following properties provided by the
 * MovementSystem class:
 * - Velocity: The sf::vector2f representing the speed of the player
 * - Position: The sf::Vector2f that represents the position of the player
 * AnimationSystem class:
 * - FrameModifier: The sf::Vector2u that represents the next animation frame to be used
 * - FrameRect: The sf::IntRect that represents which sprite rect to show next
 * 
 * Copyright (c) 2010-2012 Jacob Dix
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
